/**
This definition is used to talk to the ModuleManager Service.
Other Services register their name and where they can be located.
Modules then query this ModuleManager for a certain name, and it returns the TCP address and port where it can be located
*/
namespace java hydrap2p.modulemanager
namespace py hydrap2p.modulemanager
namespace csharp hydrap2p.modulemanager

include "service.thrift"

/**
Contains information about a registered module
*/
struct ModuleInfo {
	1:string name,		// The name of a module
	2:bool autostart, 	// Whether or not this module gets started when ModuleManager starts
	3:bool running, 	// Whether or not this module is currently running
	4:string server,	// Which server has this module
	5:bool isRemote,		// Whether this module is remote from the ModuleManager
}

service ModuleListener extends service.Service{
	/**
		Called when a new module is discovered
	*/
	oneway void addModule(1:ModuleInfo info),
	
	/**
		Called when a module changes state
	*/
	oneway void updateModule(1:ModuleInfo info),
	
	/**
		Called when a module disappears
	*/
	oneway void delModule(1:ModuleInfo info),
}

service ModuleControl extends service.Service {
	/**
		Used by the Module Manager to make a Module stop
	*/
	void stop(),
}


service ModuleManager extends service.Service{
	/**
		Returns the list of all of the modules that ModuleManager knows about
	*/
	list<ModuleInfo> getModuleList(),
	
	/**
		Sets whether the given module is automatically started
	*/
	void setModuleAutostart(1:string name, 2:string server, 3:bool autostart),
	
	/**
		Subscribes this given service to be notified of any changes in Modules
		Returns true if it worked
	*/
	bool subscribe(1:service.ServiceLocation listener),
	
	/**
		Unsubscribes this given service from being notified of any changes in Modules
	*/
	void unsubscribe(1:service.ServiceLocation listener),
	
	/**
		Starts the specific module, if it is known.
		Blocks for 10 seconds, or until the program starts
	*/
	void startModule(1:string name, 2:string server),
	
	/**
		Stops the specific module, if it is known.
	*/
	void stopModule(1:string name, 2:string server),
	
	/**
		Shuts down all known modules, then stops the Module Manager
	*/
	oneway void shutdown(),
}